﻿using Hetang.Models.DataContext;
using Hetang.Models.Helper;
using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Hetang.Views
{
    public class CheckController : Controller
    {
        protected HetangDataContext db = new HetangDataContext(DatabaseHelper.GetDatabaseConnect);

        [HttpGet]
        public ActionResult UsernameNotExist(string username)
        {
            return Json(db.tbl_Account.FirstOrDefault(a=>a.UserName == username) != null, JsonRequestBehavior.AllowGet);
        }

        [HttpGet]
        public ActionResult UsernameIsExist(string username)
        {
            return Json(db.tbl_Account.FirstOrDefault(a => a.UserName == username) == null, JsonRequestBehavior.AllowGet);
        }

        [HttpGet]
        public ActionResult EmailIsExist(string email)
        {
            return Json(db.tbl_Account.FirstOrDefault(a => a.Email == email) == null, JsonRequestBehavior.AllowGet);
        }
    }
}
